static string JS_common_bootstrap_modules = 
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief JavaScript server functions\n"
  "///\n"
  "/// @file\n"
  "///\n"
  "/// DISCLAIMER\n"
  "///\n"
  "/// Copyright 2010-2011 triagens GmbH, Cologne, Germany\n"
  "///\n"
  "/// Licensed under the Apache License, Version 2.0 (the \"License\");\n"
  "/// you may not use this file except in compliance with the License.\n"
  "/// You may obtain a copy of the License at\n"
  "///\n"
  "///     http://www.apache.org/licenses/LICENSE-2.0\n"
  "///\n"
  "/// Unless required by applicable law or agreed to in writing, software\n"
  "/// distributed under the License is distributed on an \"AS IS\" BASIS,\n"
  "/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
  "/// See the License for the specific language governing permissions and\n"
  "/// limitations under the License.\n"
  "///\n"
  "/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
  "///\n"
  "/// @author Dr. Frank Celler\n"
  "/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "// -----------------------------------------------------------------------------\n"
  "// --SECTION--                                                            Module\n"
  "// -----------------------------------------------------------------------------\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @addtogroup V8Module\n"
  "/// @{\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief module cache\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "ModuleCache = {};\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief module constructor\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function Module (id) {\n"
  "  this.id = id;\n"
  "  this.exports = {};\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief loads a file and creates a new module descriptor\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "Module.prototype.require = function (path) {\n"
  "  var raw;\n"
  "  var content;\n"
  "  var sandbox;\n"
  "  var paths;\n"
  "  var module;\n"
  "  var f;\n"
  "\n"
  "  // first get rid of any \"..\" and \".\"\n"
  "  path = this.normalise(path);\n"
  "\n"
  "  // check if you already know the module, return the exports\n"
  "  if (path in ModuleCache) {\n"
  "    return ModuleCache[path].exports;\n"
  "  }\n"
  "\n"
  "  // locate file and read content\n"
  "  raw = internal.readFile(path);\n"
  "\n"
  "  // create a new sandbox and execute\n"
  "  ModuleCache[path] = module = new Module(path);\n"
  "\n"
  "  content = \"(function (module, exports, require, print) {\" + raw.content + \"\\n/* end-of-file '\" + raw.path + \"' */ });\";\n"
  "\n"
  "  try {\n"
  "    f = SYS_EXECUTE(content, undefined, path);\n"
  "  }\n"
  "  catch (err) {\n"
  "    CONSOLE_ERROR(\"in file %s: %o\", path, err.stack);\n"
  "    throw err;\n"
  "  }\n"
  "\n"
  "  if (f == undefined) {\n"
  "    throw \"cannot create context function\";\n"
  "  }\n"
  "\n"
  "  f(module, module.exports, function(path) { return module.require(path); }, print);\n"
  "\n"
  "  return module.exports;\n"
  "};\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief normalises a path\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "Module.prototype.normalise = function (path) {\n"
  "  var p;\n"
  "  var q;\n"
  "  var x;\n"
  "\n"
  "  if (path == \"\") {\n"
  "    return this.id;\n"
  "  }\n"
  "\n"
  "  p = path.split('/');\n"
  "\n"
  "  // relative path\n"
  "  if (p[0] == \".\" || p[0] == \"..\") {\n"
  "    q = this.id.split('/');\n"
  "    q.pop();\n"
  "    q = q.concat(p);\n"
  "  }\n"
  "\n"
  "  // absolute path\n"
  "  else {\n"
  "    q = p;\n"
  "  }\n"
  "\n"
  "  // normalize path\n"
  "  n = [];\n"
  "\n"
  "  for (var i = 0;  i < q.length;  ++i) {\n"
  "    x = q[i];\n"
  "\n"
  "    if (x == \"\") {\n"
  "    }\n"
  "    else if (x == \".\") {\n"
  "    }\n"
  "    else if (x == \"..\") {\n"
  "      if (n.length == 0) {\n"
  "        throw \"cannot cross module top\";\n"
  "      }\n"
  "\n"
  "      n.pop();\n"
  "    }\n"
  "    else {\n"
  "      n.push(x);\n"
  "    }\n"
  "  }\n"
  "\n"
  "  return \"/\" + n.join('/');\n"
  "};\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief unloads module\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "Module.prototype.unload = function (path) {\n"
  "  if (! path) {\n"
  "    return;\n"
  "  }\n"
  "\n"
  "  var norm = module.normalise(path);\n"
  "\n"
  "  if (norm == \"/\" || norm == \"/internal\" || norm == \"/console\" || norm == \"/fs\") {\n"
  "    return;\n"
  "  }\n"
  "\n"
  "  delete ModuleCache[norm];\n"
  "};\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief top-level module\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "ModuleCache[\"/\"] = module = new Module(\"/\");\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief global require function\n"
  "///\n"
  "/// @FUN{require(@FA{path})}\n"
  "///\n"
  "/// @FN{require} checks if the file specified by @FA{path} has already been\n"
  "/// loaded.  If not, the content of the file is executed in a new\n"
  "/// context. Within the context you can use the global variable @CODE{exports}\n"
  "/// in order to export variables and functions. This variable is returned by\n"
  "/// @FN{require}.\n"
  "///\n"
  "/// Assume that your module file is @CODE{test1.js} and contains\n"
  "///\n"
  "/// @verbinclude modules-require-1\n"
  "///\n"
  "/// Then you can use @FN{require} to load the file and access the exports.\n"
  "///\n"
  "/// @verbinclude modules-require-2\n"
  "///\n"
  "/// @FN{require} follows the specification\n"
  "/// <a href=\"http://wiki.commonjs.org/wiki/Modules/1.1.1\">Modules/1.1.1</a>.\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function require (path) {\n"
  "  return module.require(path);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @}\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "// -----------------------------------------------------------------------------\n"
  "// --SECTION--                                                       Module \"fs\"\n"
  "// -----------------------------------------------------------------------------\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @addtogroup V8ModuleFS\n"
  "/// @{\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief fs module\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "ModuleCache[\"/fs\"] = new Module(\"/fs\");\n"
  "ModuleCache[\"/fs\"].exports.exists = FS_EXISTS;\n"
  "fs = ModuleCache[\"/fs\"].exports;\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @}\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "// -----------------------------------------------------------------------------\n"
  "// --SECTION--                                                 Module \"internal\"\n"
  "// -----------------------------------------------------------------------------\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @addtogroup V8ModuleInternal\n"
  "/// @{\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief internal module\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "ModuleCache[\"/internal\"] = new Module(\"/internal\");\n"
  "ModuleCache[\"/internal\"].exports.execute = SYS_EXECUTE;\n"
  "ModuleCache[\"/internal\"].exports.load = SYS_LOAD;\n"
  "ModuleCache[\"/internal\"].exports.log = SYS_LOG;\n"
  "ModuleCache[\"/internal\"].exports.logLevel = SYS_LOG_LEVEL;\n"
  "ModuleCache[\"/internal\"].exports.output = SYS_OUTPUT;\n"
  "ModuleCache[\"/internal\"].exports.processStat = SYS_PROCESS_STAT;\n"
  "ModuleCache[\"/internal\"].exports.read = SYS_READ;\n"
  "ModuleCache[\"/internal\"].exports.sprintf = SYS_SPRINTF;\n"
  "ModuleCache[\"/internal\"].exports.time = SYS_TIME;\n"
  "internal = ModuleCache[\"/internal\"].exports;\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief reads a file\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "internal.readFile = function (path) {\n"
  "\n"
  "  // try to load the file\n"
  "  var paths = MODULES_PATH;\n"
  "\n"
  "  for (var i = 0;  i < paths.length;  ++i) {\n"
  "    var p = paths[i];\n"
  "    var n;\n"
  "\n"
  "    if (p == \"\") {\n"
  "      n = \".\" + path + \".js\"\n"
  "    }\n"
  "    else {\n"
  "      n = p + \"/\" + path + \".js\";\n"
  "    }\n"
  "\n"
  "    if (FS_EXISTS(n)) {\n"
  "      return { path : n, content : SYS_READ(n) };\n"
  "    }\n"
  "  }\n"
  "\n"
  "  throw \"cannot find a file named '\" + path + \"' using the module path(s) '\" + MODULES_PATH + \"'\";\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief loads a file\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "internal.loadFile = function (path) {\n"
  "\n"
  "  // try to load the file\n"
  "  var paths = MODULES_PATH;\n"
  "\n"
  "  for (var i = 0;  i < paths.length;  ++i) {\n"
  "    var p = paths[i];\n"
  "    var n;\n"
  "\n"
  "    if (p == \"\") {\n"
  "      n = \".\" + path + \".js\"\n"
  "    }\n"
  "    else {\n"
  "      n = p + \"/\" + path + \".js\";\n"
  "    }\n"
  "\n"
  "    if (FS_EXISTS(n)) {\n"
  "      return SYS_LOAD(n);\n"
  "    }\n"
  "  }\n"
  "\n"
  "  throw \"cannot find a file named '\" + path + \"' using the module path(s) '\" + MODULES_PATH + \"'\";\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @}\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "// -----------------------------------------------------------------------------\n"
  "// --SECTION--                                                  Module \"console\"\n"
  "// -----------------------------------------------------------------------------\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @addtogroup V8ModuleConsole\n"
  "/// @{\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief logs debug message\n"
  "///\n"
  "/// @FUN{console.debug(@FA{format}, @FA{argument1}, ...)}\n"
  "///\n"
  "/// Formats the arguments according to @FA{format} and logs the result as\n"
  "/// debug message.\n"
  "///\n"
  "/// String substitution patterns, which can be used in @FA{format}.\n"
  "///\n"
  "/// - @LIT{\\%s} string\n"
  "/// - @LIT{\\%d}, @LIT{\\%i} integer\n"
  "/// - @LIT{\\%f} floating point number\n"
  "/// - @LIT{\\%o} object hyperlink\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function CONSOLE_DEBUG () {\n"
  "  var msg;\n"
  "\n"
  "  try {\n"
  "    msg = internal.sprintf.apply(internal.sprintf, arguments);\n"
  "  }\n"
  "  catch (err) {\n"
  "    msg = err + \": \" + arguments[0];\n"
  "  }\n"
  "\n"
  "  internal.log(\"debug\", msg);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief logs error message\n"
  "///\n"
  "/// @FUN{console.error(@FA{format}, @FA{argument1}, ...)}\n"
  "///\n"
  "/// Formats the arguments according to @FA{format} and logs the result as\n"
  "/// error message.\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function CONSOLE_ERROR () {\n"
  "  var msg;\n"
  "\n"
  "  try {\n"
  "    msg = internal.sprintf.apply(internal.sprintf, arguments);\n"
  "  }\n"
  "  catch (err) {\n"
  "    msg = err + \": \" + arguments[0];\n"
  "  }\n"
  "\n"
  "  internal.log(\"error\", msg);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief logs info message\n"
  "///\n"
  "/// @FUN{console.info(@FA{format}, @FA{argument1}, ...)}\n"
  "///\n"
  "/// Formats the arguments according to @FA{format} and logs the result as\n"
  "/// info message.\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function CONSOLE_INFO () {\n"
  "  var msg;\n"
  "\n"
  "  try {\n"
  "    msg = internal.sprintf.apply(internal.sprintf, arguments);\n"
  "  }\n"
  "  catch (err) {\n"
  "    msg = err + \": \" + arguments[0];\n"
  "  }\n"
  "\n"
  "  internal.log(\"info\", msg);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief logs log message\n"
  "///\n"
  "/// @FUN{console.log(@FA{format}, @FA{argument1}, ...)}\n"
  "///\n"
  "/// Formats the arguments according to @FA{format} and logs the result as\n"
  "/// log message.\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function CONSOLE_LOG () {\n"
  "  var msg;\n"
  "\n"
  "  try {\n"
  "    msg = internal.sprintf.apply(internal.sprintf, arguments);\n"
  "  }\n"
  "  catch (err) {\n"
  "    msg = err + \": \" + arguments[0];\n"
  "  }\n"
  "\n"
  "  internal.log(\"info\", msg);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief logs warn message\n"
  "///\n"
  "/// @FUN{console.warn(@FA{format}, @FA{argument1}, ...)}\n"
  "///\n"
  "/// Formats the arguments according to @FA{format} and logs the result as\n"
  "/// warn message.\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "function CONSOLE_WARN () {\n"
  "  var msg;\n"
  "\n"
  "  try {\n"
  "    msg = internal.sprintf.apply(internal.sprintf, arguments);\n"
  "  }\n"
  "  catch (err) {\n"
  "    msg = err + \": \" + arguments[0];\n"
  "  }\n"
  "\n"
  "  internal.log(\"warn\", msg);\n"
  "}\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @brief console module\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "ModuleCache[\"/console\"] = new Module(\"/console\");\n"
  "ModuleCache[\"/console\"].exports.debug = CONSOLE_DEBUG;\n"
  "ModuleCache[\"/console\"].exports.error = CONSOLE_ERROR;\n"
  "ModuleCache[\"/console\"].exports.info = CONSOLE_INFO;\n"
  "ModuleCache[\"/console\"].exports.log = CONSOLE_LOG;\n"
  "ModuleCache[\"/console\"].exports.warn = CONSOLE_WARN;\n"
  "console = ModuleCache[\"/console\"].exports;\n"
  "\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "/// @}\n"
  "////////////////////////////////////////////////////////////////////////////////\n"
  "\n"
  "// Local Variables:\n"
  "// mode: outline-minor\n"
  "// outline-regexp: \"^\\\\(/// @brief\\\\|/// @addtogroup\\\\|// --SECTION--\\\\|/// @page\\\\|/// @}\\\\)\"\n"
  "// End:\n"
;
